home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.06 Jun 89 / Basic Source / Help Call Projects / Help.p < prev    next >
Encoding:
Text File  |  1989-04-15  |  2.3 KB  |  74 lines  |  [TEXT/PJMM]

  1. unit getHelp;
  2.  
  3. {Procedure for Calling the Help desk accessory }
  4. {for Context Sensitive Help and Extended Alert Messages}
  5. {{Copyright ©1988 , Help Software , Inc . }
  6. { Modified by Dave Kelly for MacTutor, April 1989 }
  7. { Source code in Lightspeed Pascal 2.0 }
  8. { This procedure will open the Help DA }
  9. { Under MultiFinder , this procedure will install the Help DA in * the  }
  10. { application heap . }
  11.  
  12. interface
  13.  
  14.     procedure main;
  15.  
  16. implementation
  17.  
  18.     procedure main;
  19.  
  20.         type
  21.             LongPtr = ^LONGINT;
  22.  
  23.         var
  24.             error, Help: integer;        { Help is the desk accessory refnum }
  25.             myhandle: Handle;
  26.             name: string;
  27.             theKeyMap: longint;
  28.             theKeyMapPtr: LongPtr;
  29.  
  30.     begin
  31.         theKeyMap := $178;
  32.         Help := 0;
  33.         name := CONCAT(CHR(0), 'Help');
  34.         SetResLoad(FALSE);            { Don't load it,}
  35.         myhandle := GetNamedResource('DRVR', name);  { ...just get the handle }
  36.         error := ResError;            { -192 = Help not available }
  37.         SetResLoad(TRUE);             { Reset SetResLoad }
  38.         if (error = noErr) then
  39.             begin                        { Help is available}
  40.                 EmptyHandle(myhandle);      { Try to purge the Help DA }
  41.                 if myhandle = nil then      { If handle=NIL, it's not loaded, }
  42.                     begin
  43.                         ResrvMem(SizeResource(myhandle));  { ...reserve memory for it }
  44.                         error := MemError;         { -108 = Not enough room in heap }
  45.                     end;
  46.                 if error = noErr then       { all go .. . }
  47.                     begin
  48.                         LongPtr(theKeyMap)^ := BitOr(LongPtr(theKeyMap)^, 4);
  49.                                 { Required to work properly with MultiFinder }
  50.                                 { Press the Option key }
  51.                         Help := OpenDeskAcc(name);    { Open the Help DA }
  52.  
  53.                         if (Help < 0) and (Help = (WindowPeek(FrontWindow)^.windowKind)) then
  54.  
  55.                                     { If the Help DA open }
  56.                             begin
  57.                             end               { end if Is the Help DA open }
  58.                         else
  59.                             begin
  60.                                 error := 1;     { Let the caller know that the Help DA was not opened }
  61.                                 LongPtr(theKeyMap)^ := 0;       { Release the Option key  }
  62.                             end;
  63.                     end
  64.                 else
  65.                     begin
  66.                 { Display an Alert : Not enough memory to open Help DA  }
  67.                     end
  68.             end          {Help is Available }
  69.         else
  70.             begin
  71.                 { Display an Alert : Help DA not available }
  72.             end;    { End No Help Available}
  73.     end;           {of Help procedure }
  74. end.